<template>
  <el-select
    :value="value"
    placeholder="请选择企业"
    v-bind="$attrs"
    v-on="$listeners"
    @change="onChange"
  >
    <el-option v-for="company in companyList" :key="company.id" :label="company.companyName" :value="company.id"></el-option>
  </el-select>
</template>

<script>
import { getCompanyList } from 'api/company'

export default {
  props: {
    value: [Number, String],
  },

  data() {
    return {
      companyList: [],
    }
  },

  mounted() {
    this._getCompanyList()
  },

  methods: {
    async _getCompanyList() {
      this.companyList = await getCompanyList()
    },

    onChange(val) {
      this.$emit('input', val)
    },
  }
}
</script>
